﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using SharpShare.Storage;
using System.ComponentModel;
using SharpShare.Activation;

namespace SharpShare.Configuration {
    public abstract class StorageProviderElement : ConfigurationElement, IKeyedElement, IExtension {
        [Category("General")]
        [Description("The name of this storage provider used to identify and reference this instance in the configuration.")]
        [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
        public string Name {
            get {
                return (string)this["name"];
            }
            set {
                this["name"] = value;
            }
        }

        public abstract IStorageProvider CreateStorageProvider(IConfigurationContext context);

        public new object this[string name] {
            get {
                return base[name];
            }
            protected set {
                base[name] = value;
            }
        }

        #region IKeyedElement Members

        string IKeyedElement.Key {
            get { return this.Name; }
        }

        #endregion
    }
}
